home *** CD-ROM | disk | FTP | other *** search
- Subject: Re: Inquiring cttys
- Date: Sun, 13 Feb 94 0:29:18 CET
- From: Juergen Lock <nox@jelal.north.de>
- In-Reply-To: <9402111146.AA08333@math.uni-muenster.de>; from "Julian Reschke" at Feb 11, 94 12:46 pm
- Message-Id: <9402122329.AA00137@jelal.north.de>
-
- Julian Reschke writes:
-
- > A while back, someone (Juergen?) posted a new Fcntl for u:\proc to inquire
- > the controlling tty of a process. Please repost that one, because it would
- > be very useful for my ps.ttp...
-
- ok you want a patch... :)
-
- Index: file.h
- @@ -391,6 +391,7 @@
- #define PTRACESTEP (('P'<< 8) | 10)
- #define PTRACE11 (('P'<< 8) | 11)
- #define PLOADINFO (('P'<< 8) | 12)
- +#define PFSTAT (('P'<< 8) | 13)
-
- struct ploadinfo {
- /* passed */
- Index: procfs.c
- @@ -561,11 +561,23 @@
- *((long *)buf) = (long)&p->magic;
- return 0;
- case PBASEADDR:
- - *((long *)buf) = (long)p->base;
- + if (p == rootproc)
- + *((long *)buf) = (long)_base;
- + else
- + *((long *)buf) = (long)p->base;
- return 0;
- case PCTXTSIZE:
- *((long *)buf) = sizeof(CONTEXT);
- return 0;
- + case PFSTAT:
- + {
- + FILEPTR *pf;
- + int pfd = (*(ushort *)buf);
- + if (pfd < MIN_HANDLE || pfd >= MAX_OPEN ||
- + !(pf = p->handle[pfd]))
- + return EIHNDL;
- + return (*pf->fc.fs->getxattr)(&pf->fc, (XATTR *)buf);
- + }
- case PSETFLAGS:
- {
- int newflags = (ushort)(*(long *)buf);
-
- PFSTAT does FSTAT on processes fd passed in first word of stat buffer,
- to get the control tty use -1 and then search the `inode' in /dev or
- /pipe like in ttyname(),
-
- volatile struct stat sb;
-
- *(short *)&sb = fd; /* -1 for /dev/tty */
- if (r = Fcntl(procf, &sb, PFSTAT))
- error ...
- find device...
-
- (volatile seems necessary because of the gcc Fcntl binding(?), can this be
- fixed?)
-
- i also changed PBASEADDR to return the kernels real basepage even
- when it unlinked itself out of the chain (see main.c), that should help
- stephen read kernel memory easier etc. (btw your ps doesn't use it now
- (ADDR), right? :)
-
- later...
- Juergen
- --
- J"urgen Lock / nox@jelal.north.de / UUCP: ..!uunet!unido!uniol!jelal!nox
- ...ohne Gewehr
- PGP public key fingerprint = 8A 18 58 54 03 7B FC 12 1F 8B 63 C7 19 27 CF DA
-